system-oa/src/main/resources/mybatis/mapper/fileupload/file-upload-mapper.xml
2022-04-20 14:13:30 +08:00

392 lines
13 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="cn.com.tenlion.systemoa.dao.fileupload.IFileUploadDao">
<resultMap id="fileUploadDTO" type="cn.com.tenlion.systemoa.pojo.dtos.fileupload.FileUploadDTO">
<result column="file_upload_id" property="fileUploadId"/>
<result column="catalogue_id" property="catalogueId"/>
<result column="file_id" property="fileId"/>
<result column="file_type" property="fileType"/>
<result column="content" property="content"/>
<result column="remake" property="remake"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
<result column="file_modular" property="fileModular"/>
<result column="file_type_id" property="fileTypeId"/>
<result column="add_role" property="addRole"/>
<result column="edit_role" property="editRole"/>
<result column="del_role" property="delRole"/>
<result column="share_role" property="shareRole"/>
<result column="pdf_file_path" property="pdfFilePath"/>
</resultMap>
<resultMap id="fileUploadBO" type="cn.com.tenlion.systemoa.pojo.bos.fileupload.FileUploadBO">
<result column="file_upload_id" property="fileUploadId"/>
<result column="catalogue_id" property="catalogueId"/>
<result column="file_id" property="fileId"/>
<result column="file_type" property="fileType"/>
<result column="content" property="content"/>
<result column="remake" property="remake"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
<result column="file_modular" property="fileModular"/>
<result column="file_type_id" property="fileTypeId"/>
</resultMap>
<resultMap id="fileUploadPO" type="cn.com.tenlion.systemoa.pojo.pos.fileupload.FileUploadPO">
<result column="file_upload_id" property="fileUploadId"/>
<result column="catalogue_id" property="catalogueId"/>
<result column="file_id" property="fileId"/>
<result column="file_type" property="fileType"/>
<result column="content" property="content"/>
<result column="remake" property="remake"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
<result column="file_modular" property="fileModular"/>
<result column="file_type_id" property="fileTypeId"/>
</resultMap>
<!-- 新增文档上传 -->
<insert id="save" parameterType="map">
INSERT INTO data_file_upload(
file_upload_id,
catalogue_id,
file_type_id,
file_id,
file_type,
content,
remake,
file_modular,
pdf_file_path,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{fileUploadId},
#{catalogueId},
#{fileTypeId},
#{fileId},
#{fileType},
#{content},
#{remake},
#{fileModular},
#{pdfFilePath},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除文档上传 -->
<update id="remove" parameterType="map">
UPDATE
data_file_upload
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
file_upload_id IN
<foreach collection="fileUploadIds" index="index" open="(" separator="," close=")">
#{fileUploadIds[${index}]}
</foreach>
</update>
<!-- 删除文档上传(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
data_file_upload
WHERE
file_upload_id IN
<foreach collection="fileUploadIds" index="index" open="(" separator="," close=")">
#{fileUploadIds[${index}]}
</foreach>
</update>
<!-- 修改文档上传 -->
<update id="update" parameterType="map">
UPDATE
data_file_upload
SET
<if test="catalogueId != null and catalogueId != ''">
catalogue_id = #{catalogueId},
</if>
<if test="fileTypeId != null and fileTypeId != ''">
file_type_id = #{fileTypeId},
</if>
<if test="fileId != null and fileId != ''">
file_id = #{fileId},
</if>
<if test="fileType != null and fileType != ''">
file_type = #{fileType},
</if>
<if test="content != null and content != ''">
content = #{content},
</if>
<if test="remake != null and remake != ''">
remake = #{remake},
</if>
<if test="fileModular != null and fileModular != ''">
file_modular = #{fileModular},
</if>
<if test="pdfFilePath != null and pdfFilePath != ''">
pdf_file_path = #{pdfFilePath},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
file_upload_id = file_upload_id
WHERE
file_upload_id = #{fileUploadId}
</update>
<!-- 文档上传详情 -->
<select id="get" parameterType="map" resultMap="fileUploadDTO">
SELECT
t1.catalogue_id,
t1.file_type_id,
t1.file_id,
t1.file_type,
t1.content,
t1.remake,
t1.file_modular,
t1.pdf_file_path,
t1.file_upload_id
FROM
data_file_upload t1
WHERE
t1.is_delete = 0
<if test="fileUploadId != null and fileUploadId != ''">
AND
t1.file_upload_id = #{fileUploadId}
</if>
</select>
<!-- 文档上传详情 -->
<select id="getBO" parameterType="map" resultMap="fileUploadBO">
SELECT
t1.file_upload_id,
t1.catalogue_id,
t1.file_type_id,
t1.file_id,
t1.file_type,
t1.content,
t1.remake,
t1.file_modular,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
data_file_upload t1
WHERE
t1.is_delete = 0
<if test="fileUploadId != null and fileUploadId != ''">
AND
t1.file_upload_id = #{fileUploadId}
</if>
</select>
<!-- 文档上传详情 -->
<select id="getPO" parameterType="map" resultMap="fileUploadPO">
SELECT
t1.file_upload_id,
t1.catalogue_id,
t1.file_type_id,
t1.file_id,
t1.file_type,
t1.content,
t1.remake,
t1.file_modular,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
data_file_upload t1
WHERE
t1.is_delete = 0
<if test="fileUploadId != null and fileUploadId != ''">
AND
t1.file_upload_id = #{fileUploadId}
</if>
</select>
<!-- 文档上传列表 -->
<select id="list" parameterType="map" resultMap="fileUploadDTO">
SELECT
DISTINCT
t1.file_upload_id,
t1.catalogue_id,
t1.file_type_id,
t1.file_id,
t1.file_type,
t1.content,
t1.remake,
t1.file_modular,
t1.pdf_file_path,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete,
<if test="typeBelong != null and typeBelong != '' and typeBelong != '个人文档'">
t2.add_role,
t2.edit_role,
t2.del_role,
t2.share_role,
</if>
1
FROM
data_file_upload t1
<if test="typeBelong != null and typeBelong != '' and typeBelong != '个人文档'">
LEFT JOIN data_file_role t2 ON t1.file_upload_id = t2.file_upload_id
</if>
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.file_type_id LIKE CONCAT('%', #{keywords}, '%')
OR t1.content LIKE CONCAT('%', #{keywords}, '%')
OR t1.remake LIKE CONCAT('%', #{keywords}, '%')
OR t1.file_modular LIKE CONCAT('%', #{keywords}, '%')
OR t1.file_type LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="creator != null and creator != ''">
AND FIND_IN_SET(#{creator}, t1.creator)
<if test="typeBelong != null and typeBelong != '' and typeBelong != '个人文档'">
OR FIND_IN_SET(#{creator}, t2.user_id)
</if>
</if>
<if test="catalogueId != null and catalogueId != ''">
AND t1.catalogue_id = #{catalogueId}
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="fileUploadIds != null and fileUploadIds.size > 0">
AND
t1.file_upload_id IN
<foreach collection="fileUploadIds" index="index" open="(" separator="," close=")">
#{fileUploadIds[${index}]}
</foreach>
</if>
</select>
<!-- 文档上传列表 -->
<select id="listBO" parameterType="map" resultMap="fileUploadBO">
SELECT
t1.file_upload_id,
t1.catalogue_id,
t1.file_type_id,
t1.file_id,
t1.file_type,
t1.content,
t1.remake,
t1.file_modular,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
data_file_upload t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="fileUploadIds != null and fileUploadIds.size > 0">
AND
t1.file_upload_id IN
<foreach collection="fileUploadIds" index="index" open="(" separator="," close=")">
#{fileUploadIds[${index}]}
</foreach>
</if>
</select>
<!-- 文档上传列表 -->
<select id="listPO" parameterType="map" resultMap="fileUploadPO">
SELECT
t1.file_upload_id,
t1.catalogue_id,
t1.file_type_id,
t1.file_id,
t1.file_type,
t1.content,
t1.remake,
t1.file_modular,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
data_file_upload t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="fileUploadIds != null and fileUploadIds.size > 0">
AND
t1.file_upload_id IN
<foreach collection="fileUploadIds" index="index" open="(" separator="," close=")">
#{fileUploadIds[${index}]}
</foreach>
</if>
</select>
<!-- 文档上传统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
data_file_upload t1
WHERE
t1.is_delete = 0
</select>
</mapper>