123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- <?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.zhyc.xps.sys.mapper.DocFileMapper">
- <resultMap id="DocFileDtoResultMap" type="com.zhyc.xps.sys.dto.DocFileDto">
- <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--ID-->
- <result column="file_id" property="fileId" jdbcType="BIGINT" /><!--FILE ID-->
- <result column="file_title" property="fileTitle" jdbcType="VARCHAR" />
- <result column="dir_id" property="dirId" jdbcType="BIGINT" /><!--DIR ID-->
- <result column="file_icon" property="fileIcon" jdbcType="VARCHAR" />
- <result column="file_mime_type" property="fileMimeType" jdbcType="VARCHAR" />
- <result column="file_url" property="fileUrl" jdbcType="VARCHAR" />
- <result column="file_ext" property="fileExt" jdbcType="VARCHAR" />
- <result column="file_size" property="fileSize" jdbcType="BIGINT" />
- <result column="file_author" property="fileAuthor" jdbcType="VARCHAR" />
- <result column="file_desc" property="fileDesc" jdbcType="VARCHAR" />
- <result column="unloader_name" property="uploaderName" jdbcType="VARCHAR" />
- <result column="uploader_id" property="uploaderId" jdbcType="BIGINT" />
- <result column="uploaded_at" property="uploadedAt" jdbcType="TIMESTAMP" />
- </resultMap>
- <sql id="DocFileDto_Cols">
- A.oc_id,
- A.file_id,
- A.file_title,
- A.dir_id,
- A.file_icon,
- A.file_url,
- A.file_ext,
- A.file_mime_type,
- A.file_size,
- A.file_author,
- A.file_desc,
- A.uploaded_by AS uploader_id,
- B.account_name AS unloader_name,
- A.uploaded_at
- </sql>
- <!--根据ID获取群组信息-->
- <select id="getById" resultMap="DocFileDtoResultMap">
- SELECT
- <include refid="DocFileDto_Cols"/>
- FROM doc_file AS A
- LEFT JOIN account AS B ON (A.oc_id = B.oc_id AND A.uploaded_by = B.account_id)
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="fileId !=null">
- AND A.file_id = #{fileId ,jdbcType=BIGINT}
- </if>
- </select>
- <!--分页查询-->
- <select id="getByPage" resultMap="DocFileDtoResultMap" parameterType="java.util.Map">
- SELECT
- <include refid="DocFileDto_Cols"/>
- FROM doc_file AS A
- LEFT JOIN account AS B ON (A.oc_id = B.oc_id AND A.uploaded_by = B.account_id)
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="dirId != null">
- AND A.dir_id = #{dirId, jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND A.file_title like "%"#{keywords}"%"
- </if>
- order by A.created_at DESC
- </select>
- <!--列表查询-->
- <select id="getByList" resultMap="DocFileDtoResultMap" parameterType="java.util.Map">
- SELECT
- <include refid="DocFileDto_Cols"/>
- FROM doc_file AS A
- LEFT JOIN account AS B ON (A.oc_id = B.oc_id AND A.uploaded_by = B.account_id)
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="dirId != null">
- AND A.dir_id = #{dirId, jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND A.file_title like "%"#{keywords}"%"
- </if>
- order by A.created_at DESC
- </select>
- <!--Create-->
- <insert id="create" parameterType="com.zhyc.xps.sys.entity.DocFile">
- INSERT INTO doc_file
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="fileId != null">
- file_id,
- </if>
- <if test="fileTitle != null and fileTitle!=''">
- file_title,
- </if>
- <if test="dirId != null">
- dir_id,
- </if>
- <if test="fileUrl != null and fileUrl != ''">
- file_url,
- </if>
- <if test="fileIcon != null and fileIcon != ''">
- file_icon,
- </if>
- <if test="fileExt != null and fileExt != ''">
- file_ext,
- </if>
- <if test="fileMimeType != null and fileMimeType != ''">
- file_mime_type,
- </if>
- <if test="fileSize != null">
- file_size,
- </if>
- <if test="fileAuthor != null and fileAuthor != ''">
- file_author,
- </if>
- <if test="fileDesc != null and fileDesc != ''">
- file_desc,
- </if>
- <if test="uploadedBy != null">
- uploaded_by,
- </if>
- <if test="uploadedAt != null">
- uploaded_at,
- </if>
- <if test="createdBy != null">
- created_by,
- </if>
- <if test="createdAt != null">
- created_at,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- #{ocId ,jdbcType=BIGINT},
- </if>
- <if test="fileId != null">
- #{fileId ,jdbcType=BIGINT},
- </if>
- <if test="fileTitle != null and fileTitle!=''">
- #{fileTitle ,jdbcType=VARCHAR},
- </if>
- <if test="dirId != null">
- #{dirId ,jdbcType=BIGINT},
- </if>
- <if test="fileUrl != null and fileUrl != ''">
- #{fileUrl ,jdbcType=VARCHAR},
- </if>
- <if test="fileIcon != null and fileIcon != ''">
- #{fileIcon ,jdbcType=VARCHAR},
- </if>
- <if test="fileExt != null and fileExt != ''">
- #{fileExt ,jdbcType=VARCHAR},
- </if>
- <if test="fileMimeType != null and fileMimeType != ''">
- #{fileMimeType ,jdbcType=VARCHAR},
- </if>
- <if test="fileSize != null">
- #{fileSize ,jdbcType=BIGINT},
- </if>
- <if test="fileAuthor != null and fileAuthor != ''">
- #{fileAuthor ,jdbcType=VARCHAR},
- </if>
- <if test="fileDesc != null and fileDesc != ''">
- #{fileDesc ,jdbcType=VARCHAR},
- </if>
- <if test="uploadedBy != null">
- #{uploadedBy ,jdbcType=BIGINT},
- </if>
- <if test="uploadedAt != null">
- #{uploadedAt ,jdbcType=TIMESTAMP},
- </if>
- <if test="createdBy != null">
- #{createdBy ,jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt ,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <!--更新群组-->
- <update id="update" parameterType="com.zhyc.xps.sys.entity.DocFile">
- UPDATE doc_file
- <trim suffixOverrides=",">
- <set>
- <if test="fileTitle != null and fileTitle!=''">
- file_title = #{fileTitle ,jdbcType=VARCHAR},
- </if>
- <if test="dirId != null">
- dir_id = #{dirId ,jdbcType=BIGINT},
- </if>
- <if test="fileUrl != null and fileUrl != ''">
- file_url = #{fileUrl ,jdbcType=VARCHAR},
- </if>
- <if test="fileExt != null and fileExt != ''">
- file_ext = #{fileExt ,jdbcType=VARCHAR},
- </if>
- <if test="fileMimeType != null and fileMimeType != ''">
- file_mime_type = #{fileMimeType ,jdbcType=VARCHAR},
- </if>
- <if test="fileSize != null">
- file_size = #{fileSize ,jdbcType=BIGINT},
- </if>
- <if test="fileAuthor != null and fileAuthor != ''">
- file_author = #{fileAuthor ,jdbcType=VARCHAR},
- </if>
- <if test="fileDesc != null and fileDesc != ''">
- file_desc = #{fileDesc ,jdbcType=VARCHAR},
- </if>
- <if test="uploadedBy != null">
- uploaded_by = #{uploadedBy ,jdbcType=BIGINT},
- </if>
- <if test="uploadedAt != null">
- uploaded_at = #{uploadedAt ,jdbcType=TIMESTAMP},
- </if>
- <if test="updatedBy != null">
- updated_by = #{updatedBy ,jdbcType=BIGINT},
- </if>
- <if test="updatedAt != null">
- updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
- </if>
- </set>
- </trim>
- WHERE file_id = #{fileId ,jdbcType=BIGINT}
- <if test="ocId != null">
- AND oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- </update>
- <!--删除 -->
- <update id="delete" parameterType="java.util.Map">
- UPDATE doc_file
- <trim suffixOverrides=",">
- <set>
- <if test="deletedBy != null">
- deleted_by = #{deletedBy ,jdbcType=BIGINT},
- </if>
- <if test="deletedAt != null">
- deleted_at = #{deletedAt ,jdbcType=DATE},
- </if>
- <if test="deletedFlag != null">
- deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
- </if>
- </set>
- </trim>
- WHERE 1 = 1 AND deleted_flag = 0
- <if test="ocId != null">
- AND oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="fileId != null ">
- AND file_id = #{fileId ,jdbcType=BIGINT}
- </if>
- </update>
- <!--获取子项数目-->
- <select id="getFileCountOfDir" parameterType="java.util.Map" resultType="java.lang.Long">
- SELECT
- count(*)
- FROM doc_file AS A
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="dirId != null ">
- AND A.dir_id = #{dirId ,jdbcType=BIGINT}
- </if>
- </select>
- </mapper>
|