182 lines
4.9 KiB
XML
182 lines
4.9 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.celnet.datadump.mapper.CustomMapper">
|
|
|
|
<select id="getFields" resultType="String">
|
|
SELECT COLUMN_NAME
|
|
FROM information_schema.COLUMNS
|
|
WHERE table_name = #{tableName}
|
|
AND TABLE_SCHEMA = (SELECT DATABASE())
|
|
</select>
|
|
|
|
<select id="checkTable" resultType="String">
|
|
SELECT table_name
|
|
FROM information_schema.TABLES
|
|
WHERE table_name = #{tableName}
|
|
AND TABLE_SCHEMA = (SELECT DATABASE())
|
|
</select>
|
|
|
|
<update id="createTable">
|
|
CREATE TABLE `${tableName}` (
|
|
<foreach item="map" collection="maps">
|
|
`${map.name}` ${map.type} comment '${map.comment}',
|
|
</foreach>
|
|
<foreach item="map" collection="index">
|
|
INDEX `${map.name}`(`${map.field}`),
|
|
</foreach>
|
|
PRIMARY KEY (`id`)
|
|
) COMMENT = '${tableComment}';
|
|
</update>
|
|
|
|
<select id="getIds" resultType="String">
|
|
SELECT
|
|
id
|
|
FROM
|
|
`${tableName}`
|
|
WHERE
|
|
id IN
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</select>
|
|
|
|
|
|
<update id="updateById">
|
|
UPDATE
|
|
`${tableName}`
|
|
SET
|
|
<foreach item="map" collection="maps" open="" separator="," close="">
|
|
${map.key} = #{map.value}
|
|
</foreach>
|
|
WHERE
|
|
id = #{id}
|
|
</update>
|
|
|
|
<update id="update">
|
|
UPDATE
|
|
`${tableName}`
|
|
SET
|
|
<foreach item="map" collection="maps" open="" separator="," close="">
|
|
${map.key} = #{map.value}
|
|
</foreach>
|
|
<where>
|
|
<if test="sql != null">
|
|
${sql}
|
|
</if>
|
|
</where>
|
|
</update>
|
|
|
|
<insert id="save">
|
|
insert into
|
|
`${tableName}`
|
|
<foreach item="map" collection="maps" open="(" separator="," close=")">
|
|
${map.key}
|
|
</foreach>
|
|
values
|
|
<foreach item="map" collection="maps" open="(" separator="," close=")">
|
|
#{map.value}
|
|
</foreach>
|
|
</insert>
|
|
|
|
<insert id="saveBatch">
|
|
insert into
|
|
`${tableName}`
|
|
<foreach item="key" collection="keys" open="(" separator="," close=")">
|
|
${key}
|
|
</foreach>
|
|
values
|
|
<foreach item="value" collection="values" open="" separator="," close="">
|
|
<foreach item="item" collection="value" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="count" resultType="int">
|
|
SELECT
|
|
count(1)
|
|
FROM
|
|
`${param.api}`
|
|
<where>
|
|
<if test="param != null">
|
|
<if test="param.ids != null">
|
|
AND id IN
|
|
<foreach item="id" collection="param.ids" open="(" separator="," close=")">#{id}</foreach>
|
|
</if>
|
|
<if test="param.beginModifyDate != null">
|
|
AND ${param.updateField} >= #{param.beginModifyDate}
|
|
</if>
|
|
<if test="param.endModifyDate != null">
|
|
AND ${param.updateField} < #{param.endModifyDate}
|
|
</if>
|
|
<if test="param.beginCreateDate != null">
|
|
AND CreatedDate >= #{param.beginCreateDate}
|
|
</if>
|
|
<if test="param.endCreateDate != null">
|
|
AND CreatedDate < #{param.endCreateDate}
|
|
</if>
|
|
<if test="param.isDeleted != null">
|
|
AND IsDeleted = #{param.isDeleted}
|
|
</if>
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<select id="list" resultType="Map">
|
|
SELECT
|
|
${select}
|
|
FROM
|
|
`${api}`
|
|
<where>
|
|
<if test="sql != null">
|
|
${sql}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<select id="listById" resultType="String">
|
|
SELECT
|
|
${select}
|
|
FROM
|
|
`${api}`
|
|
<if test="sql != null">
|
|
${sql}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getById" resultType="Map">
|
|
SELECT
|
|
${select}
|
|
FROM
|
|
`${api}`
|
|
<where>
|
|
<if test="id != null">
|
|
Id = #{id}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="countBySQL" resultType="int">
|
|
SELECT
|
|
count(1)
|
|
FROM
|
|
`${api}`
|
|
<if test="sql != null">
|
|
${sql}
|
|
</if>
|
|
</select>
|
|
|
|
<delete id="delete">
|
|
delete from
|
|
`${tableName}`
|
|
<if test="ids != null">
|
|
where Parent_Type in
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
</delete>
|
|
</mapper>
|