| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <?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.gov.customs.wxjy.generator.dao.GenTableColumnMapper">
- <resultMap type="GenTableColumn" id="GenTableColumnResult">
- <result property="columnId" column="COLUMN_ID"/>
- <result property="tableId" column="TABLE_ID"/>
- <result property="columnName" column="COLUMN_NAME"/>
- <result property="columnComment" column="COLUMN_COMMENT"/>
- <result property="columnType" column="COLUMN_TYPE"/>
- <result property="javaType" column="JAVA_TYPE"/>
- <result property="javaField" column="JAVA_FIELD"/>
- <result property="isPk" column="IS_PK"/>
- <result property="isIncrement" column="IS_INCREMENT"/>
- <result property="isRequired" column="IS_REQUIRED"/>
- <result property="isInsert" column="IS_INSERT"/>
- <result property="isEdit" column="IS_EDIT"/>
- <result property="isList" column="IS_LIST"/>
- <result property="isQuery" column="IS_QUERY"/>
- <result property="queryType" column="QUERY_TYPE"/>
- <result property="htmlType" column="HTML_TYPE"/>
- <result property="dictType" column="DICT_TYPE"/>
- <result property="sort" column="SORT"/>
- <result property="createUser" column="CREATE_USER"/>
- <result property="createTime" column="CREATE_TIME"/>
- <result property="updateUser" column="UPDATE_USER"/>
- <result property="updateTime" column="UPDATE_TIME"/>
- <result property="isDeleted" column="IS_DELETED"/>
- </resultMap>
- <sql id="baseVo">
- select COLUMN_ID, TABLE_ID, COLUMN_NAME, COLUMN_COMMENT, COLUMN_TYPE, JAVA_TYPE, JAVA_FIELD, IS_PK, IS_INCREMENT, IS_REQUIRED, IS_INSERT, IS_EDIT, IS_LIST, IS_QUERY, QUERY_TYPE, HTML_TYPE, DICT_TYPE, SORT, CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME, IS_DELETED
- from SYS_GEN_TABLE_COLUMN
- </sql>
- <select id="selectList" parameterType="GenTableColumnQuery" resultMap="GenTableColumnResult">
- <include refid="baseVo"/>
- <where>
- <if test="tableId != null and tableId != ''">
- and TABLE_ID = #{tableId}
- </if>
- <if test="columnName != null and columnName != ''">
- and COLUMN_NAME like concat('%', #{columnName}, '%')
- </if>
- <if test="columnComment != null and columnComment != ''">
- and COLUMN_COMMENT = #{columnComment}
- </if>
- <if test="columnType != null and columnType != ''">
- and COLUMN_TYPE = #{columnType}
- </if>
- <if test="javaType != null and javaType != ''">
- and JAVA_TYPE = #{javaType}
- </if>
- <if test="javaField != null and javaField != ''">
- and JAVA_FIELD = #{javaField}
- </if>
- <if test="isPk != null and isPk != ''">
- and IS_PK = #{isPk}
- </if>
- <if test="isIncrement != null and isIncrement != ''">
- and IS_INCREMENT = #{isIncrement}
- </if>
- <if test="isRequired != null and isRequired != ''">
- and IS_REQUIRED = #{isRequired}
- </if>
- <if test="isInsert != null and isInsert != ''">
- and IS_INSERT = #{isInsert}
- </if>
- <if test="isEdit != null and isEdit != ''">
- and IS_EDIT = #{isEdit}
- </if>
- <if test="isList != null and isList != ''">
- and IS_LIST = #{isList}
- </if>
- <if test="isQuery != null and isQuery != ''">
- and IS_QUERY = #{isQuery}
- </if>
- <if test="queryType != null and queryType != ''">
- and QUERY_TYPE = #{queryType}
- </if>
- <if test="htmlType != null and htmlType != ''">
- and HTML_TYPE = #{htmlType}
- </if>
- <if test="dictType != null and dictType != ''">
- and DICT_TYPE = #{dictType}
- </if>
- <if test="sort != null and sort != ''">
- and SORT = #{sort}
- </if>
- <if test="createUser != null and createUser != ''">
- and CREATE_USER = #{createUser}
- </if>
- <if test="createTime != null and createTime != ''">
- and CREATE_TIME = #{createTime}
- </if>
- <if test="updateUser != null and updateUser != ''">
- and UPDATE_USER = #{updateUser}
- </if>
- <if test="updateTime != null and updateTime != ''">
- and UPDATE_TIME = #{updateTime}
- </if>
- <if test="isDeleted != null and isDeleted != ''">
- and IS_DELETED = #{isDeleted}
- </if>
- </where>
- </select>
- <select id="selectByColumnId" parameterType="String"
- resultMap="GenTableColumnResult">
- <include refid="baseVo"/>
- where COLUMN_ID = #{columnId}
- </select>
- <select id="selectGenTableColumnListByTableId" parameterType="String" resultType="GenTableColumn">
- <include refid="baseVo"/>
- where table_id = #{tableId}
- order by sort
- </select>
- <select id="selectDbTableColumnsByName" resultType="GenTableColumn">
- SELECT
- c.COLUMN_NAME as column_name,
- CASE WHEN c.NULLABLE = 'N' THEN '1' ELSE '0' END as is_required,
- CASE WHEN pk.COLUMN_NAME IS NOT NULL THEN '1' ELSE '0' END as is_pk,
- c.COLUMN_ID as sort,
- cc.COMMENTS as column_comment,
- '0' as is_increment, <!-- 暂时设为0,不判断自增列 -->
- c.DATA_TYPE as column_type
- FROM USER_TAB_COLUMNS c
- LEFT JOIN USER_COL_COMMENTS cc ON c.TABLE_NAME = cc.TABLE_NAME AND c.COLUMN_NAME = cc.COLUMN_NAME
- LEFT JOIN (
- SELECT cu.COLUMN_NAME
- FROM USER_CONS_COLUMNS cu, USER_CONSTRAINTS au
- WHERE cu.CONSTRAINT_NAME = au.CONSTRAINT_NAME
- AND au.CONSTRAINT_TYPE = 'P'
- AND au.TABLE_NAME = #{tableName}
- ) pk ON c.COLUMN_NAME = pk.COLUMN_NAME
- WHERE c.TABLE_NAME = #{tableName}
- ORDER BY c.COLUMN_ID
- </select>
- <insert id="insert" parameterType="GenTableColumn">
- insert into SYS_GEN_TABLE_COLUMN
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="columnId != null and columnId != ''">COLUMN_ID,
- </if>
- <if test="tableId != null">TABLE_ID,
- </if>
- <if test="columnName != null">COLUMN_NAME,
- </if>
- <if test="columnComment != null">COLUMN_COMMENT,
- </if>
- <if test="columnType != null">COLUMN_TYPE,
- </if>
- <if test="javaType != null">JAVA_TYPE,
- </if>
- <if test="javaField != null">JAVA_FIELD,
- </if>
- <if test="isPk != null">IS_PK,
- </if>
- <if test="isIncrement != null">IS_INCREMENT,
- </if>
- <if test="isRequired != null">IS_REQUIRED,
- </if>
- <if test="isInsert != null">IS_INSERT,
- </if>
- <if test="isEdit != null">IS_EDIT,
- </if>
- <if test="isList != null">IS_LIST,
- </if>
- <if test="isQuery != null">IS_QUERY,
- </if>
- <if test="queryType != null">QUERY_TYPE,
- </if>
- <if test="htmlType != null">HTML_TYPE,
- </if>
- <if test="dictType != null">DICT_TYPE,
- </if>
- <if test="sort != null">SORT,
- </if>
- <if test="createUser != null">CREATE_USER,
- </if>
- <if test="createTime != null">CREATE_TIME,
- </if>
- <if test="updateUser != null">UPDATE_USER,
- </if>
- <if test="updateTime != null">UPDATE_TIME,
- </if>
- <if test="isDeleted != null">IS_DELETED,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="columnId != null and columnId != ''">#{columnId},
- </if>
- <if test="tableId != null">#{tableId},
- </if>
- <if test="columnName != null">#{columnName},
- </if>
- <if test="columnComment != null">#{columnComment},
- </if>
- <if test="columnType != null">#{columnType},
- </if>
- <if test="javaType != null">#{javaType},
- </if>
- <if test="javaField != null">#{javaField},
- </if>
- <if test="isPk != null">#{isPk},
- </if>
- <if test="isIncrement != null">#{isIncrement},
- </if>
- <if test="isRequired != null">#{isRequired},
- </if>
- <if test="isInsert != null">#{isInsert},
- </if>
- <if test="isEdit != null">#{isEdit},
- </if>
- <if test="isList != null">#{isList},
- </if>
- <if test="isQuery != null">#{isQuery},
- </if>
- <if test="queryType != null">#{queryType},
- </if>
- <if test="htmlType != null">#{htmlType},
- </if>
- <if test="dictType != null">#{dictType},
- </if>
- <if test="sort != null">#{sort},
- </if>
- <if test="createUser != null">#{createUser},
- </if>
- <if test="createTime != null">#{createTime},
- </if>
- <if test="updateUser != null">#{updateUser},
- </if>
- <if test="updateTime != null">#{updateTime},
- </if>
- <if test="isDeleted != null">#{isDeleted},
- </if>
- </trim>
- </insert>
- <update id="update" parameterType="GenTableColumn">
- update SYS_GEN_TABLE_COLUMN
- <trim prefix="SET" suffixOverrides=",">
- <if test="tableId != null">TABLE_ID =
- #{tableId},
- </if>
- <if test="columnName != null">COLUMN_NAME =
- #{columnName},
- </if>
- <if test="columnComment != null">COLUMN_COMMENT =
- #{columnComment},
- </if>
- <if test="columnType != null">COLUMN_TYPE =
- #{columnType},
- </if>
- <if test="javaType != null">JAVA_TYPE =
- #{javaType},
- </if>
- <if test="javaField != null">JAVA_FIELD =
- #{javaField},
- </if>
- <if test="isPk != null">IS_PK =
- #{isPk},
- </if>
- <if test="isIncrement != null">IS_INCREMENT =
- #{isIncrement},
- </if>
- <if test="isRequired != null">IS_REQUIRED =
- #{isRequired},
- </if>
- <if test="isInsert != null">IS_INSERT =
- #{isInsert},
- </if>
- <if test="isEdit != null">IS_EDIT =
- #{isEdit},
- </if>
- <if test="isList != null">IS_LIST =
- #{isList},
- </if>
- <if test="isQuery != null">IS_QUERY =
- #{isQuery},
- </if>
- <if test="queryType != null">QUERY_TYPE =
- #{queryType},
- </if>
- <if test="htmlType != null">HTML_TYPE =
- #{htmlType},
- </if>
- <if test="dictType != null">DICT_TYPE =
- #{dictType},
- </if>
- <if test="sort != null">SORT =
- #{sort},
- </if>
- <if test="createUser != null">CREATE_USER =
- #{createUser},
- </if>
- <if test="createTime != null">CREATE_TIME =
- #{createTime},
- </if>
- <if test="updateUser != null">UPDATE_USER =
- #{updateUser},
- </if>
- <if test="updateTime != null">UPDATE_TIME =
- #{updateTime},
- </if>
- <if test="isDeleted != null">IS_DELETED =
- #{isDeleted},
- </if>
- </trim>
- where COLUMN_ID = #{columnId}
- </update>
- <delete id="deleteByColumnId" parameterType="String">
- delete
- from SYS_GEN_TABLE_COLUMN where COLUMN_ID = #{columnId}
- </delete>
- <delete id="deleteByColumnIds" parameterType="String">
- delete from SYS_GEN_TABLE_COLUMN where COLUMN_ID in
- <foreach item="columnId" collection="array" open="(" separator="," close=")">
- #{columnId}
- </foreach>
- </delete>
- <delete id="logicDelete" parameterType="String">
- update SYS_GEN_TABLE_COLUMN set is_del = 1 where COLUMN_ID = #{columnId}
- </delete>
- <delete id="deleteGenTableColumnByIds">
- delete from SYS_GEN_TABLE_COLUMN where table_id in
- <foreach collection="array" item="tableId" open="(" separator="," close=")">
- #{tableId}
- </foreach>
- </delete>
- <delete id="deleteGenTableColumns">
- delete from SYS_GEN_TABLE_COLUMN where column_id in
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item.columnId}
- </foreach>
- </delete>
- </mapper>
|