<!--表名 -->
<sql id="tableName">
DB_FHDB
</sql>
<!-- 字段 -->
<sql id="Field">
USERNAME,
BACKUP_TIME,
TABLENAME,
SQLPATH,
TYPE,
DBSIZE,
BZ,
FHDB_ID
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{USERNAME},
#{BACKUP_TIME},
#{TABLENAME},
#{SQLPATH},
#{TYPE},
#{DBSIZE},
#{BZ},
#{FHDB_ID}
</sql>
<!-- 新增-->
<insert id="save" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field"></include>
) values (
<include refid="FieldValue"></include>
)</insert>
<!-- 删除-->
<delete id="delete" parameterType="pd">
delete from
<include refid="tableName"></include>
where
FHDB_ID = #{FHDB_ID}
</delete>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
BZ = #{BZ}
where
FHDB_ID = #{FHDB_ID}
</update>
<!-- 通过ID获取数据 -->
<select id="findById" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
where
FHDB_ID = #{FHDB_ID}
</select>
<!-- 列表 -->
<select id="datalistPage" parameterType="page" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
where 1=1
<if test="pd.keywords!= null and pd.keywords != ''"><!-- 关键词检索 -->
and
(
USERNAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
or
TABLENAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
)
</if>
<if test="pd.TYPE != null and pd.TYPE != ''"><!-- 类型 -->
and TYPE = #{pd.TYPE}
</if>
<if test="pd.lastStart!=null and pd.lastStart!=''"><!-- 开始时间检索 -->
and BACKUP_TIME >= #{pd.lastStart}
</if>
<if test="pd.lastEnd!=null and pd.lastEnd!=''"><!-- 结束时间检索 -->
and BACKUP_TIME <= #{pd.lastEnd}
</if>
order by BACKUP_TIME desc
</select>
<!-- 列表(全部) -->
<select id="listAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
</select>
<!-- 批量删除 -->
<delete id="deleteAll" parameterType="String">
delete from
<include refid="tableName"></include>
where
FHDB_ID in
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</delete>