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

217 lines
8.5 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.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>
<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 id = #{id} and pro_id = #{proId}
</update>
<update id="updateFileSource">
UPDATE da_ky_sys_file_source
set
file_path = #{filePath},
source_file_name = #{sourceFileName},
file_name = #{fileName},
file_type = #{fileType},
file_size = #{fileSize},
source_type = #{sourceType},
update_user_id = #{updateUserId},
update_user_name = #{updateUserName},
update_time = now()
WHERE business_id = #{id}
</update>
<update id="updateIntegrityStatus">
UPDATE da_ky_pro_files_contents
set
integrity_status = '1'
WHERE pro_id = #{proId}
</update>
<delete id="delFileSource">
DELETE FROM da_ky_sys_file_source
WHERE business_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.*,
COALESCE(dkp2.content_name, dkp.content_name) AS parentName
FROM
da_ky_pro_files_contents dkp
LEFT JOIN da_ky_pro_files_contents dkp2 on dkp.parent_id = dkp2.id
WHERE
dkp.del_flag = '1' and dkp.pro_id = #{proId} and dkp.level in (0,1,2,3,4)
<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,
case when dkpfc.data_source = '1' then '本系统上传'
when dkpfc.data_source = '2' then '智慧现场'
else '' end AS dataSource,
dkpfc.is_unique AS isUnique,
dkpfc.integrity_status AS integrityStatus,
dkfs.id AS fileId,
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.business_id
WHERE
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
WHERE content_name = #{contentName}
and parent_id = #{parentId}
and del_flag = '1'
<if test="id != null">
and id != #{id}
</if>
</select>
<select id="getMaxSort" resultType="java.lang.Integer">
SELECT
max(dkpfc.sort)
FROM
da_ky_pro_files_contents dkpfc
WHERE
dkpfc.del_flag = '1' and dkpfc.parent_id = #{parentId}
</select>
<select id="getLevelById" resultType="java.lang.Integer">
SELECT
dkp.level
FROM
da_ky_pro_files_contents dkp
WHERE
dkp.id = #{id}
</select>
<select id="getSortById" resultType="java.lang.Integer">
SELECT
dkpfc.sort
FROM
da_ky_pro_files_contents dkpfc
WHERE
dkpfc.id = #{id}
</select>
<select id="getFilesClassifyNameStandard" resultType="com.bonus.web.domain.FilesClassifyNameStandardDto">
SELECT
dkfcns.standard_name AS standardName,
dkfcns.standard_type AS standardType
FROM
da_ky_files_classify_name_standard dkfcns
WHERE
dkfcns.del_flag = '1'
</select>
</mapper>