cm-cloud/cloud-common-plugin-dynamic/target/classes/mybatis/mapper/dynamic/config/dynamicconfigtable-mapper.xml

119 lines
3.4 KiB
XML

<?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.cm.common.plugin.dao.dynamic.config.IDynamicConfigTableDao">
<resultMap id="dynamicConfigTableDTO" type="com.cm.common.plugin.pojo.dtos.dynamic.config.DynamicConfigTableDTO">
<id property="id" column="id"/>
<result property="tableName" column="table_name"/>
<result property="tableType" column="table_type"/>
<result property="tableExplain" column="table_explain"/>
<result property="tableTemplate" column="table_template"/>
<result property="isCreate" column="is_create"/>
</resultMap>
<!-- 表新增 -->
<insert id="saveTable" parameterType="map">
INSERT INTO dynamic_config_table(
id,
table_name,
table_type,
table_explain,
table_template,
is_create,
gmt_create,
creator,
gmt_modified,
modifier,
is_delete
) VALUES(
#{id},
#{tableName},
#{tableType},
#{tableExplain},
#{tableTemplate},
#{isCreate},
#{gmtCreate},
#{creator},
#{gmtModified},
#{modifier},
#{isDelete}
)
</insert>
<!-- 表删除 -->
<update id="removeTable" parameterType="map">
UPDATE
dynamic_config_table
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
id IN
<foreach collection="ids" index="index" open="(" separator="," close=")">
#{ids[${index}]}
</foreach>
</update>
<!-- 表修改 -->
<update id="updateTable" parameterType="map">
UPDATE
dynamic_config_table
SET
<if test="tableName != null">
table_name = #{tableName},
</if>
<if test="tableType != null">
table_type = #{tableType},
</if>
<if test="tableExplain != null">
table_explain = #{tableExplain},
</if>
<if test="tableTemplate != null">
table_template = #{tableTemplate},
</if>
<if test="isCreate != null">
is_create = #{isCreate},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
id = #{id}
</update>
<!-- 表详情 -->
<select id="getTableById" parameterType="map" resultMap="dynamicConfigTableDTO">
SELECT
*
FROM
dynamic_config_table
WHERE
is_delete = 0
AND
id = #{id}
</select>
<!-- 表全部列表 -->
<select id="listTable" parameterType="map" resultMap="dynamicConfigTableDTO">
SELECT
*
FROM
dynamic_config_table
WHERE
is_delete = 0
<if test="keywords != null and keywords != ''">
AND
table_name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
</select>
</mapper>