mx_datav_gs/mxdata_v-system/target/classes/mybatis/business/MxBusinessDataMapper.xml

108 lines
3.6 KiB
XML
Raw Normal View History

2024-11-11 09:53:47 +08:00
<?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.alonginfo.project.business.mapper.MxBusinessDataMapper">
<!-- MxTableInfo 映射关系-->
<resultMap type="com.alonginfo.project.business.domain.MxTableInfo" id="MxTableInfo">
<result property="tableName" column="TABLE_NAME" />
<result property="tableComment" column="TABLE_COMMENT" />
</resultMap>
<!-- MxTableInfo 映射关系-->
<resultMap type="com.alonginfo.project.business.domain.MxTableColumn" id="MxTableColumn">
<result property="columnName" column="COLUMN_NAME" />
<result property="columnType" column="COLUMN_TYPE" />
<result property="columnComment" column="COLUMN_COMMENT" />
<result property="columnKey" column="COLUMN_KEY" />
<result property="isNullable" column="IS_NULLABLE" />
</resultMap>
<!--根据业务表开头关键字集合 查询所有的表名字和备注 TABLE_NAME,TABLE_COMENT -->
<select id="getTableInfos" resultMap="MxTableInfo">
SELECT
TABLE_NAME,
TABLE_COMMENT
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = (SELECT database())
<foreach collection="list" item="item" open="AND (" close=")" separator="OR " index="index">
<if test="item.dictValue != null and item.dictValue != ''">
TABLE_NAME LIKE CONCAT(#{item.dictValue},'%')
</if>
</foreach>
</select>
<!--根据表名称获取表的字段信息 -->
<select id="getColumnByTableName" resultMap="MxTableColumn">
SELECT
COLUMN_NAME, COLUMN_TYPE, COLUMN_COMMENT, IS_NULLABLE, COLUMN_KEY
FROM
information_schema.COLUMNS
WHERE
TABLE_SCHEMA = (select database())
AND
table_name = #{tableName}
</select>
<!--根据表名查找表数据 -->
<select id="getTableDataByTableName" resultType="map">
SELECT
*
FROM
${tableName}
</select>
<!-- 根据表名 表主键 主键值删除表数据 -->
<delete id="removeDataByKey" parameterType="map">
DELETE
FROM
${params.tableName}
WHERE
${params.tableKey} = #{params.keyValue}
</delete>
<!-- 根据表名 主键名 主键值 数据MAP 更新数据 -->
<update id="updateDataByKey" parameterType="map">
UPDATE
${params.tableName}
SET
<foreach collection="params.dataMap" index="key" item="value" separator=",">
${key} = #{value}
</foreach>
WHERE
${params.tableKey} = #{params.keyValue}
</update>
<!-- 据表名 数据MAP 插入数据 -->
<insert id="insertData" parameterType="map">
INSERT
INTO
${params.tableName}
<foreach collection="params.dataMap" index="key" separator="," open="(" close=")">
${key}
</foreach>
VALUES
<foreach collection="params.dataMap" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</insert>
<!-- 根据表名获取表注释名称 -->
<select id="getTableCNName" resultType="java.lang.String">
SELECT TABLE_COMMENT
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = (SELECT database())
AND
TABLE_NAME = #{tableName}
</select>
<delete id="delDataByTableName">
DELETE FROM ${tableName}
</delete>
</mapper>