smart_archives_service/bonus-admin/src/main/resources/mapper/FileManageMapper.xml

171 lines
7.2 KiB
XML
Raw Normal View History

2025-09-11 18:36:27 +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.bonus.web.mapper.FileManageMapper">
<insert id="saveFileManage">
INSERT INTO da_ky_pro_files_contents
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if>
<if test="proId != null and proId != ''">pro_id,</if>
<if test="contentName != null and contentName != ''">content_name,</if>
<if test="parentId != null and parentId != ''">parent_id,</if>
<if test="level != null and level != ''">`level`,</if>
<if test="sort != null">sort,</if>
<if test="markCode != null and markCode != ''">mark_code,</if>
<if test="term != null and term != ''">term,</if>
<if test="unitName != null and unitName != ''">unit_name,</if>
<if test="dataSource != null and dataSource != ''">data_source,</if>
<if test="isUnique != null and isUnique != ''">is_unique,</if>
<if test="integrityStatus != null and integrityStatus != ''">integrity_status,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createUserId != null">create_user_id,</if>
<if test="createUserName != null and createUserName != ''">create_user_name,</if>
<if test="updateUserId != null">update_user_id,</if>
<if test="updateUserName != null and updateUserName != ''">update_user_name,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="proId != null and proId != ''">#{proId},</if>
<if test="contentName != null and contentName != ''">#{contentName},</if>
<if test="parentId != null and parentId != ''">#{parentId},</if>
<if test="level != null and level != ''">#{level},</if>
<if test="sort != null">#{sort},</if>
<if test="markCode != null and markCode != ''">#{markCode},</if>
<if test="term != null and term != ''">#{term},</if>
<if test="unitName != null and unitName != ''">#{unitName},</if>
<if test="dataSource != null and dataSource != ''">#{dataSource},</if>
<if test="isUnique != null and isUnique != ''">#{isUnique},</if>
<if test="integrityStatus != null and integrityStatus != ''">#{integrityStatus},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createUserId != null">#{createUserId},</if>
<if test="createUserName != null and createUserName != ''">#{createUserName},</if>
<if test="updateUserId != null">#{updateUserId},</if>
<if test="updateUserName != null and updateUserName != ''">#{updateUserName},</if>
</trim>
</insert>
<insert id="saveFileSource" useGeneratedKeys="true" keyProperty="id">
INSERT INTO da_ky_sys_file_source
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="businessId != null and businessId != ''">business_id,</if>
<if test="filePath != null and filePath != ''">file_path,</if>
<if test="sourceFileName != null and sourceFileName != ''">source_file_name,</if>
<if test="fileName != null and fileName != ''">file_name,</if>
<if test="fileType != null and fileType != ''">file_type,</if>
<if test="sourceType != null and sourceType != ''">source_type,</if>
<if test="createUserId != null">create_user_id,</if>
<if test="createUserName != null and createUserName != ''">create_user_name,</if>
createTime
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="businessId != null and businessId != ''">#{businessId},</if>
<if test="filePath != null and filePath != ''">#{filePath},</if>
<if test="sourceFileName != null and sourceFileName != ''">#{sourceFileName},</if>
<if test="fileName != null and fileName != ''">#{fileName},</if>
<if test="fileType != null and fileType != ''">#{fileType},</if>
<if test="sourceType != null and sourceType != ''">#{sourceType},</if>
<if test="createUserId != null">#{createUserId},</if>
<if test="createUserName != null and createUserName != ''">#{createUserName},</if>
now()
</trim>
</insert>
<update id="updateFileManage">
UPDATE da_ky_pro_files_contents
<set>
id = #{id},
<if test="contentName != null and contentName != ''">content_name = #{contentName},</if>
<if test="parentId != null and parentId != ''">parent_id = #{parentId},</if>
<if test="level != null and level != ''">`level` = #{level},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="markCode != null and markCode != ''">mark_code = #{markCode},</if>
<if test="term != null and term != ''">term = #{term},</if>
<if test="unitName != null and unitName != ''">unit_name = #{unitName},</if>
<if test="dataSource != null and dataSource != ''">data_source = #{dataSource},</if>
<if test="isUnique != null and isUnique != ''">is_unique = #{isUnique},</if>
<if test="integrityStatus != null and integrityStatus != ''">integrity_status = #{integrityStatus},</if>
<if test="updateUserId != null">update_user_id = #{updateUserId},</if>
<if test="updateUserName != null and updateUserName != ''">update_user_name = #{updateUserName},</if>
update_time = now()
</set>
WHERE content_name = #{contentName}
</update>
<update id="updateFileSource">
UPDATE da_ky_sys_file_source
set
file_path = #{filePath},
source_file_name = #{sourceFileName},
file_name = #{fileName},
file_type = #{fileType},
source_type = #{sourceType},
update_user_id = #{updateUserId},
update_user_name = #{updateUserName},
update_time = now()
WHERE id = #{id}
</update>
<delete id="delFileSource">
DELETE FROM da_ky_sys_file_source
WHERE id = #{id}
</delete>
<delete id="delFileManage">
DELETE FROM da_ky_pro_files_contents
WHERE id = #{id}
</delete>
<select id="list" resultType="com.bonus.web.domain.DaKyProFilesContentsDto">
SELECT
dkp.*
FROM
da_ky_pro_files_contents dkp
WHERE
dkp.del_flag = '1' and dkp.pro_id = #{proId} and level in (0,1,2,3)
<if test="keyWord != null and keyWord != ''">
and dkp.content_name like concat('%', #{keyWord}, '%')
</if>
ORDER BY
dkp.`level`, dkp.sort
</select>
<select id="FileManage" resultType="com.bonus.web.domain.DaKyProFilesContentsDto">
SELECT
dkpfc.id AS id,
dkpfc.pro_id AS proId,
dkpfc.content_name AS contentName,
dkpfc.parent_id AS parentId,
dkpfc.level AS level,
dkpfc.sort AS sort,
dkpfc.mark_code AS markCode,
dkpfc.term AS term,
dkpfc.unit_name AS unitName,
dkpfc.data_source AS dataSource,
dkpfc.is_unique AS isUnique,
dkpfc.integrity_status AS integrityStatus,
dkfs.create_time AS createTime,
dkfs.source_file_name AS sourceFileName,
dkfs.create_user_name AS createUserName
FROM
da_ky_pro_files_contents dkpfc
left join da_ky_sys_file_source dkfs on dkpfc.id = dkfs.id
WHERE
dkfs.business_id = #{businessId} and
dkpfc.del_flag = '1' and dkpfc.parent_id = #{parentId} and dkpfc.level = 4
<if test="contentName != null and contentName != ''">
and dkpfc.content_name like concat('%', #{contentName}, '%')
</if>
order by dkpfc.create_time desc
</select>
<select id="selectFileManage" resultType="java.lang.Integer">
SELECT
count(*)
FROM
da_ky_pro_files_contents dkp
WHERE
dkp.del_flag = '1' and level = #{level}
<if test="id != null">
and id != #{id}
</if>
</select>
</mapper>